#include<bits/stdc++.h>
using namespace std;
int speed(int v,int s,int a,int vmax){
    double tim=sqrt(v*v+2*a*s);
    double sped=tim*a+v;
    if(sped>vmax) return 1;
    else if(sped<=vmax) return 0;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        int n,m,l,vmax;
        int d[100010],v[100010],a[100010],p[100010];
        cin>>n>>m>>l>>vmax;
        int flag1=0;
        int flag2=0;
        int flag3=0;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]<=0) flag1=1;//A
            if(a[i]<0||a[i]>0) flag2=1;//B
            if(a[i]>=0) flag3=1;//C
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        if(flag1==0){
            int sum=0;
            for(int i=1;i<=n;i++){
                int s=p[m]-d[i];
                if(speed(v[i],s,a[i],vmax)==1) sum++;
            }
            cout<<sum<<" ";
            if(sum==0){
                cout<<m<<endl;
            }else{
                cout<<m-1<<endl;
            }
        }else if(flag2==0){
            int sum=0;
            for(int i=1;i<=n;i++){
                if(v[i]>vmax) sum++;
            }
            cout<<sum<<" ";
            if(sum==0){
                cout<<m<<endl;
            }else{
                cout<<m-1<<endl;
            }
        }else if(flag3==0){
            int sum=0;
            int s[100010];
            int yet[100010];
            memset(yet,0,sizeof(yet));
            memset(s,-1,sizeof(s));
            for(int i=1;i<=n;i++){
                if(v[i]>vmax){
                    s[i]=(vmax*vmax-v[i]*v[i])/a[i]/2+d[i];
                }
            }
            int delet1=0;
            int delet2=11451411;
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    if(p[j]<s[i]&&p[j]>=d[i]&&yet[i]==0){
                        sum++;
                        yet[i]=1;
                        delet1=max(delet1,j);
                        delet2=min(delet2,j);
                    }
                }
            }
            cout<<sum<<" ";
            if(sum==0) cout<<m<<endl;
            else cout<<m-delet1+delet2-1<<endl;
        }
    }
    return 0;
}
